class A {
  name: string
  constructor(name:string) {
    this.name = name
  }
}

class C{ 
  name: string
  constructor(name:string) {
    this.name = name
  }
}

class Container{
  mo:any
  constructor(){
    this.mo = {}
  }
  
   provide(key:string,mo:any){
     this.mo[key] =  mo;
   }
   
   get(key:string){
      return this.mo[key]
   }
}

class B{
  a:any
  c:any
  constructor (mo:Container){
    this.a = mo.get('a')
    this.c = mo.get('c')
  }
}

const mo = new Container();
mo.provide('a',new A('xiaohong'))
mo.provide('c',new A('newking'))

//取出
const get = new B(mo)
console.log(get.a);
console.log(get.c);
